﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using RM2012Service.Business;
using RM2012Service.Controller;
using RM2012Service.DataAccess;

namespace RM2012Service
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class RM2012Service : System.Web.Services.WebService
    {
        #region USER GROUP
        /*-----------------------------------------------------------------------
         * USER GROUP
        /----------------------------------------------------------------------*/
        [WebMethod]
        public UserGroupInfo[] GetAllGroup()
        {
            return new UserGroupCtrl().GetAllGroup();
        }

        [WebMethod]
        public UserGroupInfo GetGroupById(string groupId)
        {
            return new UserGroupCtrl().GetGroupById(groupId);
        }

        [WebMethod]
        public UserGroupInfo[] GetGroupByLikeId(string groupId)
        {
            return new UserGroupCtrl().GetGroupByLikeId(groupId);
        }

        [WebMethod]
        public UserGroupInfo[] GetGroupByName(string groupName)
        {
            return new UserGroupCtrl().GetGroupByName(groupName);
        }

        [WebMethod]
        public UserGroupInfo GetGroupByUserId(string userId)
        {
            return new UserGroupCtrl().GetGroupByUserId(userId);
        }

        [WebMethod]
        public bool AddGroup(UserGroupInfo info)
        {
            return new UserGroupCtrl().AddGroup(info);
        }

        [WebMethod]
        public bool UpdateGroup(UserGroupInfo info)
        {
            return new UserGroupCtrl().UpdateGroup(info);
        }

        [WebMethod]
        public bool DeleteGroup(string groupId)
        {
            return new UserGroupCtrl().DeleteGroup(groupId);
        }
        #endregion


        #region USER
        /*-----------------------------------------------------------------------
         * USER
        /----------------------------------------------------------------------*/
        [WebMethod]
        public UsersInfo[] GetAllUsers()
        {
            return new UsersCtrl().GetAllUsers();
        }

        [WebMethod]
        public UsersInfo GetUserById(string userId)
        {
            return new UsersCtrl().GetUserById(userId);
        }

        [WebMethod]
        public UsersInfo GetUserByUserName(string userName)
        {
            return new UsersCtrl().GetUserByUserName(userName);
        }

        [WebMethod]
        public UsersInfo[] GetUserByFullName(string fullName)
        {
            return new UsersCtrl().GetUserByFullName(fullName);
        }

        [WebMethod]
        public UsersInfo[] GetUserByAddress(string address)
        {
            return new UsersCtrl().GetUserByAddress(address);
        }

        [WebMethod]
        public UsersInfo[] GetUserByPhone(string phone)
        {
            return new UsersCtrl().GetUserByPhone(phone);
        }

        [WebMethod]
        public UsersInfo[] GetUserByEmail(string email)
        {
            return new UsersCtrl().GetUserByEmail(email);
        }

        [WebMethod]
        public UsersInfo[] GetUserByGroup(string groupId)
        {
            return new UsersCtrl().GetUserByGroup(groupId);
        }

        [WebMethod]
        public bool UserHasGroup(string userId)
        {
            return new UsersCtrl().UserHasGroup(userId);
        }

        [WebMethod]
        public bool ExistUserByUserName(string userName)
        {
            return new UsersCtrl().ExistUserByUserName(userName);
        }

        [WebMethod]
        public bool ExistUserByUserNameAndPassword(string userName, string passWord)
        {
            return new UsersCtrl().ExistUserByUserNameAndPassword(userName, passWord);
        }

        [WebMethod]
        public UserGroupInfo GetUserGroup(string userId)
        {
            return new UsersCtrl().GetUserGroup(userId);
        }

        [WebMethod]
        public bool AddUser(UsersInfo info)
        {
            return new UsersCtrl().AddUser(info);
        }

        [WebMethod]
        public bool UpdateUser(UsersInfo info)
        {
            return new UsersCtrl().UpdateUser(info);
        }

        [WebMethod]
        public bool UpdateUserNoPass(UsersInfo info)
        {
            return new UsersCtrl().UpdateUserNoPass(info);
        }

        [WebMethod]
        public bool UpdateProfile(UsersInfo info)
        {
            return new UsersCtrl().UpdateProfile(info);
        }

        [WebMethod]
        public bool ChangePassword(string userId, string passWord)
        {
            return new UsersCtrl().ChangePassword(userId, passWord);
        }

        [WebMethod]
        public string GetIdByUsername(string userName)
        {
            return new UsersCtrl().GetIdByUsername(userName);
        }

        [WebMethod]
        public bool DeleteUser(string userId)
        {
            return new UsersCtrl().DeleteUser(userId);
        }
        #endregion


        #region PERMISSION
        /*-----------------------------------------------------------------------
         * PERMISSION
        /----------------------------------------------------------------------*/
        public PermissionInfo[] GetAllPermission()
        {
            return new PermissionCtrl().GetAllPermission();
        }

        public bool AddPermission(PermissionInfo info)
        {
            return new PermissionCtrl().AddPermission(info);
        }

        public bool UpdatePermission(PermissionInfo info)
        {
            return new PermissionCtrl().UpdatePermission(info);
        }

        public bool DeletePermissionByUserId(string userId)
        {
            return new PermissionCtrl().DeletePermissionByUserId(userId);
        }

        public bool DeletePermissionByUserGroupId(string userGroupId)
        {
            return new PermissionCtrl().DeletePermissionByUserGroupId(userGroupId);
        }
        #endregion


        #region TABLE
        /*-----------------------------------------------------------------------
         * TABLE
        /----------------------------------------------------------------------*/
        [WebMethod]
        public TablesInfo[] GetAllTables()
        {
            return new TablesCtrl().GetAllTables();
        }

        [WebMethod]
        public TablesInfo[] GetTableByArea(string areaId)
        {
            return new TablesCtrl().GetTableByArea(areaId);
        }

        [WebMethod]
        public TablesInfo GetTableById(string tablesId)
        {
            return new TablesCtrl().GetTableById(tablesId);
        }

        [WebMethod]
        public TablesInfo[] GetTableByState(int state)
        {
            return new TablesCtrl().GetTableByState(state);
        }

        [WebMethod]
        public DataSet GetTableByStateDataSet(int state)
        {
            return new TablesCtrl().GetTableByStateDataSet(state);
        }

        [WebMethod]
        public bool UpdateTableState(string tablesId, int stateId)
        {
            return new TablesCtrl().UpdateTableState(tablesId, stateId);
        }
        #endregion


        #region AREA
        /*-----------------------------------------------------------------------
         * AREA
        /----------------------------------------------------------------------*/
        [WebMethod]
        public AreaInfo[] GetAllArea()
        {
            return new AreaCtrl().GetAllArea();
        }

        [WebMethod]
        public AreaInfo GetAreaById(string areaId)
        {
            return new AreaCtrl().GetAreaById(areaId);
        }

        [WebMethod]
        public string GetAreaIdByName(string areaName)
        {
            return new AreaCtrl().GetAreaIdByName(areaName);
        }
        #endregion


        #region MENU
        /*-----------------------------------------------------------------------
         * MENU
        /----------------------------------------------------------------------*/
        [WebMethod]
        public MenuInfo[] GetAllMenu()
        {
            return new MenuCtrl().GetAllMenu();
        }

        [WebMethod]
        public DataTable GetAllMenuDataTable()
        {
            return new MenuCtrl().GetAllMenuDataTable();
        }

        [WebMethod]
        public DataSet GetAllMenuDataSet()
        {
            return new MenuCtrl().GetAllMenuDataSet();
        }

        [WebMethod]
        public MenuInfo GetMenuById(string menuId)
        {
            return new MenuCtrl().GetMenuById(menuId);
        }
        #endregion


        #region CUSTOMER
        /*-----------------------------------------------------------------------
         * CUSTOMER
        /----------------------------------------------------------------------*/
        [WebMethod]
        public DataSet GetAllCustomer()
        {
            return new CustomerCtrl().GetAllCustomer();
        }

        [WebMethod]
        public DataSet GetCustomerLastDataSet()
        {
            return new CustomerCtrl().GetCustomerLastDataSet();
        }

        [WebMethod]
        public CustomerInfo GetCustomerLast()
        {
            return new CustomerCtrl().GetCustomerLast();
        }

        [WebMethod]
        public bool AddCustomer(CustomerInfo info)
        {
            return new CustomerCtrl().Add(info);
        }

        [WebMethod]
        public bool UpdateCustomer(CustomerInfo info)
        {
            return new CustomerCtrl().Update(info);
        }

        [WebMethod]
        public bool UpdateCustomerSex(String cusId)
        {
            return new CustomerCtrl().UpdateSex(cusId);
        }
        #endregion


        #region BOOKING
        /*-----------------------------------------------------------------------
         * BOOKING
        /----------------------------------------------------------------------*/
        [WebMethod]
        public DataSet GetAllBooking()
        {
            return new BookingCtrl().GetAllBooking();
        }
        #endregion


        #region INVOICE
        /*-----------------------------------------------------------------------
         * INVOICE
        /----------------------------------------------------------------------*/
        [WebMethod]
        public DataSet GetAllInvoice()
        {
            return new InvoiceCtrl().GetAllInvoice();
        }

        [WebMethod]
        public DataSet GetAllInvoicePaid()
        {
            return new InvoiceCtrl().GetAllInvoicePaid();
        }

        [WebMethod]
        public DataSet GetAllInvoiceNotPaid()
        {
            return new InvoiceCtrl().GetAllInvoiceNotPaid();
        }

        [WebMethod]
        public DataSet GetAllInvoiceById(string invoiceId)
        {
            return new InvoiceCtrl().GetAllInvoiceById(invoiceId);
        }

        [WebMethod]
        public bool AddInvoice(InvoiceInfo info)
        {
            return new InvoiceCtrl().Add(info);
        }

        [WebMethod]
        public bool UpdateInvoice(InvoiceInfo info)
        {
            return new InvoiceCtrl().Update(info);
        }

        [WebMethod]
        public bool UpdateInvoiceTotal(InvoiceInfo info)
        {
            return new InvoiceCtrl().UpdateTotal(info);
        }

        [WebMethod]
        public bool UpdateInvoicePaid(InvoiceInfo info)
        {
            return new InvoiceCtrl().UpdatePaid(info);
        }

        [WebMethod]
        public bool UpdateInvoiceNeeded(InvoiceInfo info)
        {
            return new InvoiceCtrl().UpdateNeeded(info);
        }

        [WebMethod]
        public bool DeleteInvoice(String invoiceId)
        {
            return new InvoiceCtrl().Delete(invoiceId);
        }
        #endregion


        #region INVOICE DETAIL
        /*-----------------------------------------------------------------------
         * INVOICE DETAIL
        /----------------------------------------------------------------------*/
        [WebMethod]
        public DataSet GetInvoiceDetailByInvoiceId(string invoiceId)
        {
            return new InvoiceDetailCtrl().GetInvoiceDetailByInvoiceId(invoiceId);
        }

        [WebMethod]
        public DataSet GetInvoiceDetailByMenuAndInvoice(String invoiceId, String menuId)
        {
            return new InvoiceDetailCtrl().GetInvoiceDetailByMenuAndInvoice(invoiceId, menuId);
        }

        [WebMethod]
        public bool AddInvoiceDetail(InvoiceDetailInfo info)
        {
            return new InvoiceDetailCtrl().AddInvoiceDetail(info);
        }

        [WebMethod]
        public bool UpdateInvoiceDetail(InvoiceDetailInfo info)
        {
            return new InvoiceDetailCtrl().UpdateInvoiceDetail(info);
        }

        [WebMethod]
        public bool DeleteInvoiceDetail(InvoiceDetailInfo info)
        {
            return new InvoiceDetailCtrl().DeleteInvoiceDetail(info);
        }
        #endregion
    }
}
